package com.zy.service.Impl;

import com.zy.mapper.UserMapper;
import com.zy.pojo.User;
import com.zy.service.CrudService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements CrudService {

    @Autowired(required = false)
    UserMapper userMapper;


    @Override
    public int add(User user) {
        System.out.println("service"+user.toString());
        return userMapper.insert(user);
    }

    @Override
    public int delete(int id) {
        return userMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int update(User user) {
        return userMapper.updateByPrimaryKey(user);
    }

    @Override
    public User queryById(int id) {
        return userMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<User> queryAll() {
        return userMapper.selectAll();
    }
}
